<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>dom绑定数据</title>
</head>

<body>
  <div id="msg"></div>
  <div>
    <input type="text" id="inputmsg">
  </div>

  <script>
    // 数据源  model
    let data = {
      msg: '你好dom'
    }

    // 得到数据要展示在页面的dom节点
    document.querySelector('#msg').innerHTML = data.msg
    document.querySelector('#inputmsg').value = data.msg

    document.querySelector('#inputmsg').addEventListener('input', e => {
      data.msg = e.target.value
    })

    setTimeout(() => {
      document.querySelector('#msg').innerHTML = Date.now()
    }, 3000);


  </script>

</body>

</html>